{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=767
  Verdict: Accepted
}
uses SysUtils;
 
var
	i,n,m,j,k:longint;
	a,b:array[0..100010] of longint;
 
procedure sort(var a:array of longint; l,r:longint);
var
	i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
	while a[i]<x do inc(i);
	while a[j]>x do dec(j);
	if i<=j then begin
		y:=a[i];
		a[i]:=a[j];
		a[j]:=y;
		inc(i);
		dec(j);
	end;
until i>j;
if l<j then sort(a,l,j);
if i<r then sort(a,i,r);
end;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n);
for i:=1 to n do read(a[i]);
read(m);
for i:=1 to m do read(b[i]);
sort(a,1,n);
sort(b,1,m);
i:=1;
j:=1;
while a[i]=a[i+1] do inc(i);
while b[j]=b[j+1] do inc(j);
while (i<n) and (j<m) do begin
	if a[i]<>b[j] then begin
		write('NO');
		halt;
	end else begin
		repeat
			inc(i);
		until a[i]<>a[i+1];
		repeat
			inc(j);
		until b[j]<>b[j+1];
	end;
end;
if (i<>n) or (j<>m) then write('NO') else write('YES');
end.